<?php
require_once( 'Classes/Datasources/DatasourceDecorator.php' );

class Filtration extends DatasourceDecorator {

	var $oFilter;
	
	function Filtration( $oDatasource, $oFilter ){
		$this->DatasourceDecorator( $oDatasource );
		$this->oFilter     = $oFilter;
	}

	function ShouldIncludeTable( $sTableName ) {
		return $this->oFilter->ShouldIncludeTable( $sTableName );
	}
	
	function GetTableList() {
		$aReturnList = array();
		foreach ( $this->oDatasource->GetTableList() as $sThisTable ) {
			if ( $this->ShouldIncludeTable( $sThisTable ) ) {
				$aReturnList[] = $sThisTable;
			}
		}
		return $aReturnList;
	}

	function GetColumnList( $sTableName ) {
		if ( !$this->ShouldIncludeTable( $sTableName ) ) {
			return array();	
		}
		return $this->oDatasource->GetColumnList( $sTableName );
	}
	
	function GetPrimaryKey( $sTableName ) {
		if ( !$this->ShouldIncludeTable( $sTableName ) ) {
			return array();	
		}
		return $this->oDatasource->GetPrimaryKey( $sTableName );
	}
	
	function GetTables() {
		$aTables = $this->oDatasource->GetTables();
		
		$aReturnedTables = array();
		foreach( $aTables as $oThisTable ) {
			if ( $this->ShouldIncludeTable( $oThisTable->GetName() ) ) {
				$aReturnedTables[ $oThisTable->GetName() ] = $oThisTable;
			}
		}
		return $aReturnedTables;
	}
}


?>
